﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TuLing.Blazor.Migrations
{
    public partial class removeNavi : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_PurchaseOrderDetails_Products_ProductId",
                table: "PurchaseOrderDetails");

            migrationBuilder.DropForeignKey(
                name: "FK_PurchaseOrderDetails_PurchaseOrders_Id",
                table: "PurchaseOrderDetails");

            migrationBuilder.DropForeignKey(
                name: "FK_PurchaseOrders_Customers_CustomerId",
                table: "PurchaseOrders");

            migrationBuilder.DropForeignKey(
                name: "FK_SupplierLogs_PurchaseOrders_PurchaseOrderId",
                table: "SupplierLogs");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PurchaseOrders",
                table: "PurchaseOrders");

            migrationBuilder.DropIndex(
                name: "IX_PurchaseOrders_CustomerId",
                table: "PurchaseOrders");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PurchaseOrderDetails",
                table: "PurchaseOrderDetails");

            migrationBuilder.DropIndex(
                name: "IX_PurchaseOrderDetails_ProductId",
                table: "PurchaseOrderDetails");

            migrationBuilder.RenameTable(
                name: "PurchaseOrders",
                newName: "BuyOrders");

            migrationBuilder.RenameTable(
                name: "PurchaseOrderDetails",
                newName: "BuyOrderDetails");

            migrationBuilder.AddPrimaryKey(
                name: "PK_BuyOrders",
                table: "BuyOrders",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_BuyOrderDetails",
                table: "BuyOrderDetails",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_BuyOrderDetails_BuyOrders_Id",
                table: "BuyOrderDetails",
                column: "Id",
                principalTable: "BuyOrders",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_SupplierLogs_BuyOrders_PurchaseOrderId",
                table: "SupplierLogs",
                column: "PurchaseOrderId",
                principalTable: "BuyOrders",
                principalColumn: "Id");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_BuyOrderDetails_BuyOrders_Id",
                table: "BuyOrderDetails");

            migrationBuilder.DropForeignKey(
                name: "FK_SupplierLogs_BuyOrders_PurchaseOrderId",
                table: "SupplierLogs");

            migrationBuilder.DropPrimaryKey(
                name: "PK_BuyOrders",
                table: "BuyOrders");

            migrationBuilder.DropPrimaryKey(
                name: "PK_BuyOrderDetails",
                table: "BuyOrderDetails");

            migrationBuilder.RenameTable(
                name: "BuyOrders",
                newName: "PurchaseOrders");

            migrationBuilder.RenameTable(
                name: "BuyOrderDetails",
                newName: "PurchaseOrderDetails");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PurchaseOrders",
                table: "PurchaseOrders",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PurchaseOrderDetails",
                table: "PurchaseOrderDetails",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrders_CustomerId",
                table: "PurchaseOrders",
                column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrderDetails_ProductId",
                table: "PurchaseOrderDetails",
                column: "ProductId");

            migrationBuilder.AddForeignKey(
                name: "FK_PurchaseOrderDetails_Products_ProductId",
                table: "PurchaseOrderDetails",
                column: "ProductId",
                principalTable: "Products",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PurchaseOrderDetails_PurchaseOrders_Id",
                table: "PurchaseOrderDetails",
                column: "Id",
                principalTable: "PurchaseOrders",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PurchaseOrders_Customers_CustomerId",
                table: "PurchaseOrders",
                column: "CustomerId",
                principalTable: "Customers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_SupplierLogs_PurchaseOrders_PurchaseOrderId",
                table: "SupplierLogs",
                column: "PurchaseOrderId",
                principalTable: "PurchaseOrders",
                principalColumn: "Id");
        }
    }
}
